<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <link rel="stylesheet" th:href="@{/}+'js/jquery.mloading/jquery.mloading.css'" media="all">
    <script th:src="@{/}+'js/jquery.mloading/jquery.mloading.js'"></script>
    <link rel="stylesheet" href="layuiadmin/plugins/dtree/dtree/dtree.css">
    <style type="text/css">
        .layui-table-tool {
            position: relative;
            z-index: 1;
            width: 100%;
            min-height: 50px;
            line-height: 30px;
            padding: 10px 15px;
            border-width: 0 0 1px;
        }
    </style>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <div class="layui-row">
                <form class="layui-form" lay-filter="myform" id="myform">
                    <input type="reset" id="btReset" class="layui-hide" >
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">选择试卷</label>
                            <div class="layui-input-inline">
                                <input type="text" name="paperName" id="paperName"  autocomplete="off" class="layui-input" select>
                                <input type="hidden" name="paperId" id="paperId">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">参赛队</label>
                            <div class="layui-input-inline">
                                <ul id="nodeOrgId" name="nodeOrgId" class="dtree" data-id="0" ></ul>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <div class="layui-btn-group">
                                <button type="button" class="layui-btn layui-btn-primary" data-type="query"><i class="layui-icon">&#xe615;</i>查询</button>
                                <button type="button" class="layui-btn layui-btn-primary" data-type="resetBtn"><i class="layui-icon">&#xe669;</i>重置</button>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
            <div class="row">
                <table class="layui-hide"  id="main-table" lay-filter="main-table"></table>
            </div>
        </div>
    </div>
</div>

<script th:inline="none"></script>
<script>
    layui.extend({
        dtree: '{/}layuiadmin/plugins/dtree/dtree/dtree'
    });
    layui.use(['table','form','element','dtree'], function(){
        var table = layui.table,
            $ = layui.$,
            dtree = layui.dtree,
            form = layui.form;
        var orgTree = dtree.renderSelect({
            elem: "#nodeOrgId",
            url: "org/getDTree",
            checkbar: false ,
            selectTips: "选择部门",
            done:function(a,b,c){

            }
        });
        table.render({
            elem: '#main-table'
            ,height: (top.height-85)+'px'
            ,url: 'dateScore/teamWeekNum'
            ,title: '排名列表'
            ,page: true
             ,toolbar: '#toolbar'
            ,limit:20
            ,cols: [
                [
                    {type: 'numbers'}
                    ,{field: 'weekNo', title: "第几周",width:280}
                    ,{field: 'copyNum', title: "答题次数",width:280}

                ]
            ]
            ,done:function(){
            }
        });
        table.on('row(main-table)', function(obj){
            clickLayTableRow(table,form,'main-table',obj);
        });
        $("#paperName").on("click",function(){
            top.layer.open({
                id:"openwin",
                type: 2,
                title:'选择试卷',
                area:['1300px','750px'],
                content:  'rooter?url=ksxt/stat/paper-select',
                btn:['选择','关闭'],
                yes:function(index,layero){
                    var iframeWin = top[layero.find('iframe')[0]['name']];
                    let r = iframeWin.getId();
                    $("#paperId").val(r.id);
                    $("#paperName").val(r.name);
                    top.layer.close(index);
                }
            });
        })
        table.on('toolbar(main-table)', function(obj){
            switch(obj.event){
                case 'excel':
                    $("#app").mLoading({text:"正在导出，请稍后"});
                    $("#hideForm").attr("action","dateScore/excelWeekNum").submit();
                    $("#app").mLoading("hide");
                    break;
            }
        })
        var $ = layui.$, active = {
            query: function(){
                let orgId = $(":input[name=nodeOrgId_select_nodeId]").val();
                table.reload("main-table",{where:{paperId:$("#paperId").val(),orgId: orgId}})

            },
            resetBtn:function () {
                $("#btReset").click();

            }
        };
        $('.layui-form .layui-btn').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

    });

</script>
<script type="text/html" id="toolbar">
    <div class="layui-btn-group">
        <button class="layui-btn layui-btn-sm layui-btn-normal" lay-event="excel"><i class="layui-icon layui-icon-file"></i>导出</button>
    </div>
</script>
</body>
</html>